#include<reg52.h>
sbit p37=P3^7;
sbit p36=P3^6;
sbit p35=P3^5;
sbit p34=P3^4;
sbit p33=P3^3;
sbit p20=P2^0;
sbit p21=P2^1;
sbit p22=P2^2;
sbit p23=P2^3;
sbit p24=P2^4;
sbit p07=P0^7;
sbit p17=P1^7;
code unsigned int shu1[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
						0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10} ;
unsigned int a1,a2,a3,a,b,c,d,f,g,sec,min,time,b1,i=1,j,b2,g1,m,k,k1,p[3],n,n1,q,hour;
unsigned long e;
xianshi()
{
    if(m==1)
    {
    a1=a%10;
    P0=shu1[a1];p20=p21=1;p22=0;
    if(g==0|g==1)
    {a2=a/10%10;
    P0=shu1[a2+10];p20=p22=1;p21=0;
	}		                       
    else
    {
    a2=a/10%10;
    P0=shu1[a2];p20=p22=1;p21=0;
    }	
    a3=a/100%10;
    P0=shu1[a3];p21=p22=1;p20=0;
   
    }
	else P0=0xff;	
}
main()
{
    	   p23=1;	  g=0;

	    
    TMOD=0x01;
    TH0=0xEE;
    TL0=0x00;
    EA=1;
    ET0=1;
    TR0=1;	 
	m=1;	
	 p33=1;  q=10; a=10;
	while(1)
	{
			for(j=0;j<100;j++);
		   
			if(p35==0)
			{	if(q==0)q=0;
				 else q--;
				for(j=0;j<20000;j++);
			 }
		
			if(p36==0)
			{	if(q==999)q=999;
				else q++;
				for(j=0;j<20000;j++);
			}
		
			if(p34==0)
			{
				m=-m;
			}
			while(~p34);
			
			
			if(a==0)
			{
				p33=0;	p23=0;
			}
		    else
			{
				a=q-hour*10-(int)(min/6);xianshi();	if(a<100)p20=1;
				p23=1;
			}


		}

}
timer0() interrupt 1
{
    TH0=0xEE; 
    TL0=0x00;
    b++;c++;
    if(b==200)
	{	if(g1==1)
		{	g++;
			if(g>2)  g=0;
		}
		sec++;
		b=0;
	}
	if(sec==60)
	{
		min++;
		sec=0;
	}
	if(min==60)
    {
	 	hour++;
		min=0;
	}
	if(hour==24)
	{
		hour=0;
	}


}


